package com.shop.cereshop.agent.service.voucher.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.cereshop.agent.dao.voucher.AgentVoucherDAO;
import com.shop.cereshop.agent.service.voucher.AgentVoucherService;
import com.shop.cereshop.commons.constant.IntegerEnum;
import com.shop.cereshop.commons.domain.voucher.CereAgentVoucher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * 代金券服务实现类
 */
@Service
public class AgentVoucherServiceImpl extends ServiceImpl<AgentVoucherDAO, CereAgentVoucher>
    implements AgentVoucherService {

  @Autowired
  private AgentVoucherDAO agentVoucherDAO;

  @Override
  public CereAgentVoucher getAreaVoucher(BigDecimal amount) {
    //根据金额查询城市代金券
    return lambdaQuery().eq(CereAgentVoucher::getState, IntegerEnum.STATE_ENABLE)
            .eq(CereAgentVoucher::getFaceValue, amount)
            .one();
  }
}
